<?php
namespace Zxf5115\Laravel\Problem\Logics;

use Illuminate\Http\Request;

/**
 * @author zhangxiaofei [<1326336909@qq.com>]
 * @dateTime 2025-10-08
 *
 * 常见问题逻辑处理类
 */
class ProblemLogic
{
  /**
   * 常见问题数据处理
   *
   * @param Request $request 用户请求参数
   * @param string $modelClass 操作模型类
   * @return void
   */
  public function handle(Request $request, string $modelClass) : void
  {
    $model = $modelClass::firstOrNew(['id' => $request->id]);

    $model->category_id = $request->category_id;
    $model->title = $request->title;
    $model->content = $request->content ?? '';
    $model->save();
  }
}
